<?php

namespace app\admin\controller; 
use app\common\controller\Backend;
use think\Db;
use think\Config;
use jm\wechat\WeChatWithdraw;//根目录\extend\jm\wechat\WeChatWithdraw
/**
 * 提现管理
 *
 * @icon fa fa-circle-o
 */
class Withdraw extends Backend
{
    
   
    /**
     *微信提现
     *
     */
    public function wechat(){
        $amount =  1; //$amount,$re_openid
        $re_openid='oDitr5LMJcO5HtIYhhCb5XdQ3rCw'; 
        $appid=Config::get("site.Applets_appid");
        // $appid=Config::get("site.wechat_pay_appid");
       $data= ["appid"=>$appid];
        // $data=   ["appid"=>"1","mch_id"=>"1","key"=>"1","apiclient_cert"=>"1","apiclient_key"=>"1"]
        $WeChatWithdraw=new WeChatWithdraw($data);
        $WeChatWithdrawpay=$WeChatWithdraw->WechatWithdrawal($re_openid,$amount);
        var_dump($WeChatWithdrawpay);die; 

    }

    /**
     *微信退款
     *
     */
    public function Refund(){
        $total_fee =  1; //退款金额  单位元
        $order_sn='支付订单号'; 
        //$out_refund_no 商户退款单号 自定义而已
        $out_refund_no = 'refund'.time();
        $appid=Config::get("site.Applets_appid");
        // $appid=Config::get("site.wechat_pay_appid");
       $data= ["appid"=>$appid];
        // $data=   ["appid"=>"1","mch_id"=>"1","key"=>"1","apiclient_cert"=>"1","apiclient_key"=>"1"]
        $WeChatWithdraw=new WeChatRefund($data);
        $WeChatWithdrawpay=$WeChatWithdraw->Refund($total_fee,$Refund_fee,$order_sn,$out_refund_no);
        var_dump($WeChatWithdrawpay);die; 

    }
    

}
